package org.yray.ufiletools.file;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class CleanGitFile {

    private static List<String> rmDirList=new ArrayList<>();
    static {
        rmDirList.add("target");
        rmDirList.add(".git");
        rmDirList.add(".idea");
    }
    public static void main(String[] args) throws IOException {
        File file=new File("D:\\project\\icsp\\trunk\\design_implementation");
        rmFile(file);
    }

    private static void rmFile(File fileDir) throws IOException {
        for(File subFile:fileDir.listFiles())
        {
            if(subFile.isDirectory())
            {
                String fileName=subFile.getName();
                if(rmDirList.indexOf(fileName)>-1)
                {
                    System.out.println(fileName);
                    FileUtils.forceDelete(subFile);
                }
                else {
                    rmFile(subFile);
                }
            }

        }
    }
}
